<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id='app'>
        <button @click="flag=!flag">切换动画</button>
        <transition @before-enter="beforeEnter" @enter="enter" @after-enter="afterEnter">
            <h3 v-if="flag">天亮教育</h3>
        </transition>
    </div>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                flag: true
            },
            methods: {
                beforeEnter(el) {
                    console.log("进场之前");
                    // debugger
                    el.style.opactiy = "0"
                    el.style.transform = 'translateX(-400px)'
                },
                enter(el) {
                    // 执行这个后，浏览器刷新了动画
                    el.offsetWidth;

                    console.log("进场");
                    el.style.transition = "all 1s ease"
                    el.style.opactiy = "1"
                    el.style.transform = "translateX(0)"
                },
                afterEnter(el) {
                    console.log("进场之后");
                }
            },
        })
    </script>
</body>

</html>